package com.oceansoft.mobile.econsole.scheduled;

import com.oceansoft.mobile.econsole.modules.expireWarn.service.ExpireWarnService;
import com.oceansoft.mobile.econsole.modules.jlapi.entity.ExpireWarnQueryEntity;
import com.oceansoft.mobile.econsole.modules.jlapi.entity.InQueryServiceInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName: ExpireWarnTask
 * Desc: 过期提醒定时器
 * Date： 2016/10/27
 * Created：shaom
 */
@Component(value = "expireWarnTask")
public class ExpireWarnTask {
    private static final Logger logger = LoggerFactory.getLogger(ExpireWarnTask.class);

    @Resource
    private ExpireWarnService expireWarnService;

    /**
     * 身份证到期
     */
    public void iCExpireMessage() throws Exception {
        logger.info("++++  身份证到期定时任务启动 +++");
        List<ExpireWarnQueryEntity> expireEntities = expireWarnService.getTodayExpireData(InQueryServiceInfo.API_011);
        if (!expireEntities.isEmpty()) {
            expireWarnService.pushMsg(expireEntities);
        } else {
            logger.info("++++  身份证到期定时任务结束: 没有查询需要的数据 +++");
        }
    }

    /**
     * 驾驶证到期
     */
    public void vLExpireMessage() {
        logger.info("++++  驾驶证到期定时任务启动 +++");
        List<ExpireWarnQueryEntity> expireEntities = expireWarnService.getTodayExpireData(InQueryServiceInfo.API_012);
        if (!expireEntities.isEmpty()) {
            expireWarnService.pushMsg(expireEntities);
        } else {
            logger.info("++++  驾驶证到期定时任务结束: 没有查询需要提醒的数据 +++");
        }
    }

    /**
     * 年检到期提醒
     */
    public void aIExpireMessage() {
        logger.info("++++  年检到期定时任务启动 +++");
        List<ExpireWarnQueryEntity> expireEntities = expireWarnService.getTodayExpireData(InQueryServiceInfo.API_013);
        if (!expireEntities.isEmpty()) {
            expireWarnService.pushMsg(expireEntities);
        } else {
            logger.info("++++  年检到期定时任务结束: 没有查询需要提醒的数据 +++");
        }
    }

    /**
     * 车辆违法
     */
    public void vVExpireMessage() {
        logger.info("++++  车辆违法定时任务启动 +++");
        List<ExpireWarnQueryEntity> expireEntities = expireWarnService.getTodayExpireAttData(InQueryServiceInfo.API_014);
        if (!expireEntities.isEmpty()) {
            expireWarnService.pushMsg(expireEntities);
        } else {
            logger.info("++++  车辆违法定时任务结束: 没有查询需要提醒的数据 +++");
        }
    }


}
